package com.yq.light.knowledgeDB.code.service.impl;


import com.yq.light.commons.code.entity.KnowledgeDb;
import com.yq.light.commons.code.entity.KnowledgeFile;
import com.yq.light.knowledgeDB.code.dao.KnowledgeDBDao;
import com.yq.light.knowledgeDB.code.service.KnowledgeDBService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("knowledgeDBService")
@Transactional
@Slf4j
public class KnowledgeDBServiceImpl implements KnowledgeDBService {

    @Autowired
    private KnowledgeDBDao knowledgeDBDao;

    /**
     * select用户的知识库列表，并返回数据给前端
     *
     * @param ownerAccount
     * @return
     */
    @Override
    public List<KnowledgeDb> fetchUserKnowledgeDbList(String ownerAccount) {
        List<KnowledgeDb> list = knowledgeDBDao.fetchUserKnowledgeDbList(ownerAccount);
        return list;
    }

    /**
     * select用户的知识库中的文件列表，并返回数据给前端
     *
     * @param ownerAccount
     * @param fileTitle
     * @return
     */
    @Override
    public List<KnowledgeFile> fetchUserKnowledgeDbFileList(String ownerAccount, String fileTitle) {
        List<KnowledgeFile> list = knowledgeDBDao.fetchUserKnowledgeDbFileList(ownerAccount,fileTitle);
        return list;
    }

    /**
     * insert新建一个知识库
     *
     * @param knowledgeDb
     * @return
     */
    @Override
    public int newKnowledgeDb(KnowledgeDb knowledgeDb) {
        int result = 0;
        result = knowledgeDBDao.newKnowledgeDb(knowledgeDb);
        return result;
    }

    /**
     * insert新建一个知识库中的文件
     *
     * @param knowledgeFile
     * @return
     */
    @Override
    public int newKnowledgeFile(KnowledgeFile knowledgeFile) {
        int result = 0;
        result = knowledgeDBDao.newKnowledgeFile(knowledgeFile);
        return result;
    }

    /**
     * update知识库中的文件
     *
     * @param knowledgeFile
     * @return
     */
    @Override
    public String updateKnowledgeDbFile(KnowledgeFile knowledgeFile) {
        String result = null;
        result = knowledgeDBDao.updateKnowledgeFile(knowledgeFile);
        return null;
    }
}
